<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let obj = {
            name:"张三",
            age:10,
            sex:"男"
        }

        obj[Symbol.iterator] = objectEntries;

        function* objectEntries(obj){
			//获取对象所有的key保存到数组[name,age]
			const propkeys = Object.keys(obj);
            // console.log(propkeys);
			for(const propkey of propkeys){
				yield [propkey,obj[propkey]];
				
			}
        }
        let  it = objectEntries(obj);
        
        console.log(it.next());
        console.log(it.next());
        console.log(it.next());
        console.log(it.next());

    </script>
</body>
</html>